import "./public-path";//文件开头导入配置的包
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import "@/assets/index.css";
Vue.config.productionTip = false
import "@/mock"

//代码进度条展示效果
import NProgress from "nprogress"; // 导入 nprogress模块
import "nprogress/nprogress.css"; // 导入样式，否则看不到效果
NProgress.configure({ showSpinner: false }); // 显示右上角螺旋加载提示

//组件库
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI);

//导入自定义指令
import LazyLoad from './plugins/LazyLoad';
Vue.use(LazyLoad);
//引入axios对象
import axios from "@/utils/request";
Vue.prototype.$axios = axios;
//插件的使用
import user from "@/utils/user";
Vue.use(user);

let instance = null;
function render(props = {}) {
  const { container } = props;
  instance = new Vue({
    router,
    store,
    render: (h) => h(App),
  }).$mount(container ? container.querySelector('#app') : '#app');
}



// 独立运行时
if (!window.__POWERED_BY_QIANKUN__) {
  render();
}

export async function bootstrap() {
  console.log('[vue] vue app bootstraped');
}
export async function mount(props) {
  console.log('[vue] props from main framework', props);
  render(props);
}
export async function unmount() {
  instance.$destroy();
  instance.$el.innerHTML = '';
  instance = null;
  // router = null;
}
